package com.stlm2.dems.sns.entity.base;

import com.stlm2.dems.sns.entity.Platform;
import com.stlm2.dems.sns.entity.Sms;
import com.stlm2.dems.sns.entity.SmsState;

import java.io.Serializable;
import java.util.Date;



/**
 * 短信
 *
 */
public abstract class BaseSms implements Serializable {

	private int hashCode = Integer.MIN_VALUE;

	/**
	 * 唯一标识
	 */
	private Integer id;
	
	/**
	 * 短信状态
	 */
	private SmsState smsState;
	
	/**
	 * 发送时间
	 */
	private Date sendTime;
	
	/**
	 * 用户ID
	 */
	private Integer userId;
	
	/**
	 * 使用时间
	 */
	private Date useTime;
	
	/**
	 * 验证码
	 */
	private String code;
	
	/**
	 * 发送平台
	 */
	private Platform platform;
	
	/**
	 * 接收手机
	 */
	private String mobile;
	
	/**
	 * 第三方平台的唯一标识符
	 */
	private String sid;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public SmsState getSmsState() {
		return smsState;
	}

	public void setSmsState(SmsState smsState) {
		this.smsState = smsState;
	}

	public Date getSendTime() {
		return sendTime;
	}

	public void setSendTime(Date sendTime) {
		this.sendTime = sendTime;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public Date getUseTime() {
		return useTime;
	}

	public void setUseTime(Date useTime) {
		this.useTime = useTime;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Platform getPlatform() {
		return platform;
	}

	public void setPlatform(Platform platform) {
		this.platform = platform;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getSid() {
		return sid;
	}

	public void setSid(String sid) {
		this.sid = sid;
	}

	//-------枚举映射---------
	public Integer getSmsStateValue(){
		return (smsState != null) ? smsState.getIntValue() : null;
	}
	
	public void setSmsStateValue(Integer v){
		if(v != null)
			smsState = SmsState.getByIntValue(v);
	}
	
	public Integer getPlatformValue(){
		return (platform != null) ? platform.getIntValue() : null;
	}
	
	public void setPlatformValue(Integer v){
		if(v != null)
			platform = Platform.getByIntValue(v);
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		if (!(obj instanceof Sms)) {
			return false;
		} else {
			Sms sms = (Sms) obj;
			if (this.getId() == null || sms.getId() == null)
				return false;
			else
				return (this.getId().equals(sms.getId()));
		}
	}

	@Override
	public int hashCode() {
		if (Integer.MIN_VALUE == this.hashCode) {
			if (this.getId() == null)
				return super.hashCode();
			else {
				String hashStr = this.getClass().getName() + ":"
						+ this.getId().hashCode();
				this.hashCode = hashStr.hashCode();
			}
		}

		return this.hashCode;
	}

}
